﻿using Application.Allot_dService;
using Application.Allot_hService;
using Domain.Entity;
using Domain.Entity.tr;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;

namespace WMSManage.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class Allot_dController : ControllerBase
    {
        public readonly IAllot_dService allot_dService;
        public Allot_dController(IAllot_dService allot_dService)
        {
            this.allot_dService = allot_dService;
        }

        /// <summary>
        /// ID查
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<Allot_d>> GetAllot_d(int id)
        {
            List <Allot_d> d = await allot_dService.GetAllot_d(id);
            return d;
        }

        /// <summary>
        /// 调拨统计
        /// </summary>
        /// <param name="CurrentPage"></param>
        /// <param name="proc_code"></param>
        /// <param name="al_code"></param>
        /// <param name="al_type"></param>
        /// <param name="header_create_by"></param>
        /// <param name="type_id"></param>
        /// <param name="proc_primary_unit"></param>
        /// <param name="al_user"></param>
        /// <param name="out_wh_id"></param>
        /// <param name="in_wh_id"></param>
        /// <param name="instock_status"></param>
        /// <param name="outstock_status"></param>
        /// <param name="startTime"></param>
        /// <param name="endTime"></param>
        /// <param name="createstartTime"></param>
        /// <param name="createendTime"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<FenYe<AllotTJResult>> GetAllotTJResult(int CurrentPage, string? proc_code, string? al_code, string? al_type, string? header_create_by, int? type_id, string? proc_primary_unit, string? al_user, int? out_wh_id, int? in_wh_id, [FromQuery] int[]? instock_status, [FromQuery] int[]? outstock_status, string? startTime, string? endTime, string? createstartTime, string? createendTime)
        {
            FenYe<AllotTJResult> fenYe = new FenYe<AllotTJResult>()
            {
                CurrentPage = CurrentPage,
            };
            FenYe<AllotTJResult> allotTJResults = await allot_dService.GetAllotTJResult(fenYe, proc_code, al_code, al_type, header_create_by, type_id, proc_primary_unit, al_user, out_wh_id, in_wh_id, instock_status, outstock_status, startTime, endTime, createstartTime, createendTime);
            return allotTJResults;
        }
    }
}
